//
//  Interrupts.c
//  ARDUINO_PROPELLER
//
//  Created by FRANCIS PAPINEAU on 12-02-06.
//  Copyright 2012 carleton university. All rights reserved.
//

void wakeUpNow(){
    checkVar = true;
}

// --------------------------------------------------------------

void brown_Out_Detect(void){
    
    pinInterrupt = 2;
    send_INT_Header_DATA();
    
    sendError(false, RunTimeAddress);
    
    restart();
}

// --------------------------------------------------------------

void start_Stop(void){
    start_stop = !start_stop;
    pinInterrupt = 1;
    send_INT_Header_DATA();
}

// --------------------------------------------------------------

void toggleDebug(void){
    debug = !debug;
    pinInterrupt = 3;
    send_INT_Header_DATA();
    toggleDEBUGLED();
}

// --------------------------------------------------------------

bool attach_Start_Stop_INT(void){
    
    chackVar = true;
    
    attachInterrupt(4, start_Stop, FALLING);
    
    if(checkVar){
        return true;
    }else{
        sendError(false, INTAddress);
        return false;
    }
    
}

// --------------------------------------------------------------

bool attach_Debug_INT(void){
    
    chackVar = true;
    
    attachInterrupt(1, toggleDebug, FALLING);
    
    if(checkVar){
        return true;
    }else{
        sendError(false, INTAddress);
        return false;
    }
    
}


// --------------------------------------------------------------

bool attach_Brownout_INT(void){
    
    chackVar = true;
    attachInterrupt(5, brown_Out_Detect, FALLING);
    
    if(checkVar){
        return true;
    }else{
        sendError(false, INTAddress);
        return false;
    }
}

